<?php

namespace app\mobileapp\controller;

class Package extends Base
{

    /**
     * User: Simony
     * Function:套餐列表
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function gePackageList()
    {

        $memberId = $this->memberId;

        $member = model('common/member/Member')->getInfoByID($memberId);
        $sex = $member['sex'];

        $packageModel = model('common/package/Package');

        $where = [
            'is_show' => 1
        ];
        $package_list = $packageModel->getList($where, 0, 'id,name,is_red,day,price,desc,market_price', 'is_red desc,sort asc');
        $level_auth = moduleConfig('level_auth');

        $list = [];
        foreach ($package_list as $v) {
            $level = 2;
            $v['member_num'] = $level_auth['view_member_num'][$sex][$level] ?? 0;
            $v['member_hide_info_num'] = $level_auth['day_view_member_social_account_num'][$sex][$level] ?? 0;
            $v['burn_start'] = $level_auth['read_after_burn'][$sex][0] ?? 0;
            $v['burn_end'] = $level_auth['read_after_burn'][$sex][$level] ?? 0;
            $v['dynamic_num'] = $level_auth['day_release_dynamic_num'][$sex][$level] ?? 0;
            $v['program_num'] = $level_auth['day_release_program_num'][$sex][$level] ?? 0;
            $list[] = $v;
        }

        $data = [
            'list' => $list,
            'member_id' => $member['id'],
            'available_balance' => $member['available_balance']
        ];


        $this->api_ajaxReturn(SUCCESS, '获取成功', $data);
    }


}